using System;
using System.Windows.Forms;

namespace Woz
{
    /// <summary>
    /// removes the currently selected screen thumbnail from the associated screen 
    /// thumbnail slider the selects the screen thumbnail visually above it if possible
    /// </summary>
    internal class RemoveScreenThumbnailAction : Woz.Action
    {
        /// <summary>
        /// default constructor
        /// </summary>
        /// <param name="pSlider">parent slider to execute action on</param>
        public RemoveScreenThumbnailAction(Woz.ScreenThumbnailSlider pSlider)
        {
            // save the parameters to our members
            this.mSlider = pSlider;

            // save this screen thumbnail incase we want to undo
            this.mScreenThumbnailToRemove = this.mSlider.SelectedScreenThumbnail;
        }

        /// <summary>
        /// gets the name of the tool this action belongs to none in this case
        /// </summary>
        public override string ToolName
        {
            get
            {
                return "";
            }
        }

        /// <summary>
        /// gets whether this action can be propagated or not
        /// </summary>
        public override bool Propagatable
        {
            get
            {
                return false;
            }
        }

        /// <summary>
        /// removes the currently selected screen thumbnail in the parent screen thumbnail slider
        /// </summary>
        /// <param name="pScreen">not used for non propagateable action</param>
        protected override void OnExecute(Woz.Screen pScreen)
        {
            // tell the parent slider to remove this thumbnail
            this.mSlider.RemoveScreenThumbnail(this.mScreenThumbnailToRemove);
        }

        /// <summary>
        /// unremoves the screen thumbnail that was removed
        /// </summary>
        /// <param name="pScreen">not used for non propagateable action</param>
        protected override void OnUnExecute(Woz.Screen pScreen)
        {
            // add this screen thumbnail back to the parent slider
            this.mSlider.AddScreenThumbnail(this.mScreenThumbnailToRemove);
        }

        /// <summary>
        /// slider from which we will remove the currently selected screen thumbnail
        /// </summary>
        private Woz.ScreenThumbnailSlider mSlider;

        /// <summary>
        /// remember the screen thumbnail that we remove incase of undoing
        /// </summary>
        private Woz.ScreenThumbnail mScreenThumbnailToRemove;
    }
}
